#include<bits/stdc++.h>

#define rp(i,a,b) for(int i=a;i<b;++i)
#define rrp(i,b,a) for(int i=b;i>=a;--i)

using namespace std;

struct node{
	int first,second;
};

map<int,int>record;
std::vector<node> v;


bool cmp(node a,node b){
	if(a.second!=b.second)
		return a.second>b.second;
	else
		return a.first<b.first;
}

int main(){
	int n;scanf("%d", &n);
	rp(i , 0 , n)
	{
		int num;scanf("%d",&num);
		record[num]++;
	}
	map<int,int>::iterator it;
	for(it = record.begin();it != record.end();++it){
		node tmp;
		tmp.first=it->first;tmp.second=it->second;
		v.push_back(tmp);
	}
	sort(v.begin(),v.end(),cmp);

	rp(i , 0 , v.size()){
		printf("%d %d\n", v[i].first,v[i].second);
	}
	return 0;
}